package com.dokimall.order.web;

import com.dokimall.common.utils.R;
import com.dokimall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.UUID;

@Controller
public class PageController {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @GetMapping("/{page}.html")
    public String page(@PathVariable("page") String page){
        return page;
    }

    @ResponseBody
    @GetMapping("/releseorder")
    public String releseorder(){
        OrderEntity orderEntity = new OrderEntity();
        String string = UUID.randomUUID().toString();
        orderEntity.setOrderSn(string);
        rabbitTemplate.convertAndSend("order-event-exchange","order.create.order",orderEntity);
        return "Ok";
    }

}
